function ishuan (head) {
    if (!head || !head.next) return false;
    let slow = head;
    let fast = head.next;
    while (slow !== fast && fast?.next) {
        slow = slow.next;
        fast = fast.next.next;
    }
    return slow === fast;
}

function huanStart (head) {
    if (!head || !head.next) return null;
    let fast = slow = head;
    while (fast?.next) {
        slow = slow.next;
        fast = fast.next.next;
        if (slow === fast) {
            slow = head;
            while (slow === fast) {
                slow = slow.next;
                fast = slow.next;
            }
            return slow;
        }
    }
    return false;
}
function getNum (n) {
    let sum = 0;
    while(n>0) {
      const d = n % 10;
      sum += d*d;
      n = Math.floor(n / 10);
    }
    return sum;
}
function isHappy (n) {
    let slow = n;
    let fast = getNum(n);
    while (slow !== fast && fast !== 1) {
        slow = getNum(slow);
        fast = getNum(getNum(fast));
    }
    return slow === fast;
}
function reverse (prev, cur) {
    if (!cur) return prev;
    const tem = cur.next;
    cur.next = prev;
    return reverse(cur, tem);
}
function reverseLink (head) {
    return reverse(null, head)
}